package com.ean.backpack.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ean.backpack.domain.Countrylist;
import com.ean.backpack.repository.CountrylistRepository;
import com.ean.backpack.service.CountrylistService;

@Service
@Transactional
public class CountrylistServiceImpl implements CountrylistService {

	@Autowired
	CountrylistRepository countrylistRepository;

	public long countAllCountrylists() {
		return countrylistRepository.count();
	}

	public void deleteCountrylist(Countrylist countrylist) {
		countrylistRepository.delete(countrylist);
	}

	public Countrylist findCountrylist(Integer id) {
		return countrylistRepository.findOne(id);
	}

	public List<Countrylist> findAllCountrylists() {
		return countrylistRepository.findAll();
	}

	public List<Countrylist> findCountrylistEntries(int firstResult,
			int maxResults) {
		return countrylistRepository.findAll(
				new org.springframework.data.domain.PageRequest(firstResult
						/ maxResults, maxResults)).getContent();
	}

	public void saveCountrylist(Countrylist countrylist) {
		countrylistRepository.save(countrylist);
	}

	public Countrylist updateCountrylist(Countrylist countrylist) {
		return countrylistRepository.save(countrylist);
	}
}
